#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

// 1984. 学生分数的最小差值
// https://leetcode.cn/problems/minimum-difference-between-highest-and-lowest-of-k-scores/description/

class Solution {
public:
    int minimumDifference(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());

        int n = nums.size();
        int left = 0;
        int ans = INT_MAX;
        for (int i = k -1; i < n; i++){
            ans = min(nums[i] - nums[left], ans);
            left++;
        }
        return ans;
    }
};

int main()
{
    return 0;
}